package com.itheima.dao;

import com.itheima.pojo.Comment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface CommentMapper extends Mapper<Comment> {

    @Select("select count(*) from t_comment")
    int findCommentCount();

    @Update("update t_comment set to_uid='' and to_user_uid='' where user_uid=#{userUid}")
    void closeEmailNotification(@Param("userUid") String userUid);

    /**
     * 通过userUid获取对象
     * @param userUid
     * @return
     */
    @Select("select * from t_comment where user_uid=#{userUid}")
    List<Comment> getCommentListByUserUid(@Param("userUid") String userUid);

    /**
     * 获取用户的点赞列表
     *
     * @return
     */
    @Select("select * from t_comment where TYPE='1'")
    List<Comment> getPraiseListByUser();

    /**
     * 通过uid查询评论对象
     *@param uid
     * @return
     */
    @Select("select * from t_comment where uid=#{uid}")
    Comment getByUid(@Param("uid") String uid);
}
